#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int TEST_CASES = 12;
random_device rd;
mt19937 gen(rd());

// 生成一个随机整数
int randomInt(int min, int max) {
    return uniform_int_distribution<int>(min, max)(gen);
}

// 生成测试用例
void test(int testCase, ofstream& fout) {
    if (testCase == 1) {
        // 样例1
        fout << "5 3\n";
    } else if (testCase == 2) {
        // 样例2
        fout << "3 5\n";
    } else if (testCase <= 6) {
        // N > M 的情况
        int N = randomInt(5, 10);
        int M = randomInt(1, N-1);
        fout << N << " " << M << "\n";
    } else if (testCase <= 10) {
        // N <= M 的情况
        int N = randomInt(1, 10);
        int M = randomInt(N, 10);
        fout << N << " " << M << "\n";
    } else {
        // 边界情况
        int type = randomInt(1, 4);
        if (type == 1) {
            fout << "1 1\n";  // 最小值
        } else if (type == 2) {
            fout << "10 10\n";  // 最大值
        } else if (type == 3) {
            fout << "1 10\n";   // N最小，M最大
        } else {
            fout << "10 1\n";   // N最大，M最小
        }
    }
}

void mk_in() {
    // 创建testdata目录
    if (system("rm -rf testdata/*.in testdata/*.out testdata/*.zip") != 0) {
        cerr << "清理旧数据失败" << endl;
    }
    
    if (system("mkdir -p testdata") != 0) {
        cerr << "创建testdata目录失败" << endl;
        return;
    }

    cout << "开始生成输入数据..." << endl;
    for (int i = 1; i <= TEST_CASES; ++i) {
        string in_name = "testdata/" + to_string(i) + ".in";
        ofstream fout(in_name);
        if (!fout) {
            cerr << "无法打开文件 " << in_name << endl;
            continue;
        }
        
        test(i, fout);
        fout.close();
        cout << "生成【" << setw(2) << setfill('0') << i << ".in】数据成功" << endl;
    }
    cout << "输入数据生成完成" << endl << endl;
}

void mk_out() {
    cout << "开始生成输出数据..." << endl;
    for (int i = 1; i <= TEST_CASES; ++i) {
        string in_name = "testdata/" + to_string(i) + ".in";
        string out_name = "testdata/" + to_string(i) + ".out";
        string cmd = "./std < " + in_name + " > " + out_name;
        
        // 显示当前处理进度
        cout << "处理测试用例 【" << setw(2) << setfill('0') << i << "】...";
        cout.flush();
        
        int result = system(cmd.c_str());
        if (result != 0) {
            cerr << "\n生成【" << setw(2) << setfill('0') << i << ".out】数据失败" << endl;
        } else {
            cout << " 完成" << endl;
        }
    }
    cout << "输出数据生成完成" << endl;
}

int main() {
    // 编译标准程序
    cout << "编译标准程序..." << endl;
    if (system("g++ std.cpp -o std -std=c++17") != 0) {
        cerr << "编译标准程序失败" << endl;
        return 1;
    }
    cout << "编译标准程序成功" << endl << endl;

    mk_in();
    mk_out();
    
    // 清理可执行文件
    if (system("rm -f std") != 0) {
        // 非致命错误，不终止程序
        cout << "清理临时文件失败" << endl;
    }
    
    return 0;
}